﻿@model Proggy.Web.Cms.Core.PropertyTypes.DragAndDrop
@{
    // get config object
    var configObject = Model.GetConfigObject<DragAndDropConfigObject>();

    // add to backend
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/Scripts/Proggy.CorePropertyTypes.js", BackEndContentType.JavaScript);
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/Scripts/Proggy.CorePropertyTypes.DragAndDrop.js", BackEndContentType.JavaScript);
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/Css/DragAndDropEditor.css", BackEndContentType.Stylesheet);
    Html.RenderBackEndContentForLightboxPartial();
    
    // get node id
    var nodeId = Convert.ToInt32(this.ViewContext.RouteData.Values["id"]);
    
    // remove parts
    DragAndDropManager.RemoveAddedPartsForNodeId(nodeId);
}
<noscript><div class="proggy-noscript">THIS EDITOR WILL NOT WORK WITHOUT JAVASCRIPT TURNED ON AND IT WOULD BE DANGEROUS TO USE THE EDITOR WHILST JAVASCRIPT IS TURNED OFF. PLEASE TURN JAVASCRIPT ON.</div></noscript>
@foreach (var _p in DragAndDropManager.AddedPartsCache)
{
    <h4>@_p.UniqueId</h4>
}
<div class="dand-addnew">
    @Html.ActionLink("Add new >>", "Add", new { area = "ProggyCore", controller = "DragAndDrop", a = configObject.AllowedParts, nodeId=nodeId }, new { @class = "proggy-button-go dand-addnew-link proggy-lb-link-init" })
</div>
<div id="@(Model.PropertyNameStart)_savedata">
</div>
<div style="margin-left: -0.0625em; height: @(configObject.HeightEm)em; width: @(configObject.WidthEm + configObject.WidthAdjustEm)em;overflow:hidden;">
    <iframe 
        src="javascript:''" 
        id="@(Model.PropertyNameStart)_iframe" 
        scrolling="yes" 
        style="width: @(configObject.WidthEm + configObject.WidthAdjustEm)em; height: @(configObject.HeightEm + configObject.HeightAdjustEm)em; border: none; overflow-y: scroll;">
    </iframe>
</div>
<div style="display:none;" id="@(Model.PropertyNameStart)_iframecontentdiv">
    @{
        Html.RenderPartial("~/Areas/ProggyCore/Views/DragAndDrop/DragAndDropIFrame.cshtml", Model);   
    }
</div>
<script type="text/javascript">

    // init
    Proggy.Static.WaitForTypesToRegister(function () {

        var dAndD = new Proggy.CorePropertyTypes.DragAndDrop();
        dAndD.Init("@(Model.PropertyNameStart)", "@(configObject.AreaId)", "@(Model.PropertyNameStart)_iframe", "@(Model.PropertyNameStart)_iframecontentdiv", "@(Model.PropertyNameStart)_savedata");

    });

</script>
@{

    //// DUMMY
    //var rssJson = Newtonsoft.Json.JsonConvert.SerializeObject(new Proggy.Web.Cms.Core.PropertyTypes.RssReader
    //{
    //    Count = 5,
    //    FeedUrl = "http://feeds.bbci.co.uk/news/video_and_audio/uk/rss.xml",
    //    Name = "Test Reader!",
    //    MoreUrl = "http://moreurl"

    //});
    
}
@*DUMMY*@ @*<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[0].PartName" value="RjRss" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[0].Order" value="1" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[0].Width" value="20em" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[0].Float" value="left" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[0].ConfigData" value="@rssJson" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[1].PartName" value="RjRss" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[1].Order" value="2" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[1].Width" value="30em" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[1].Margin" value="0 0 0 10em" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[1].Float" value="left" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[1].ConfigData" value="@rssJson" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[2].PartName" value="RjRss" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[2].Order" value="0" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[2].Width" value="60em" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[2].Clear" value="both" />
<input type="hidden" name="@(Model.PropertyNameStart).AddedDragAndDropItems[2].ConfigData" value="@rssJson" />*@
@*END DUMMY*@